package main

import (
	"github.com/cz-it/aps/src/handler"

	"net/http"
)

func RootHdl(w http.ResponseWriter, r *http.Request){
	w.Write([]byte("Root Page"))
}

func WeiboHdl(w http.ResponseWriter, r *http.Request){
	w.Write([]byte(r.FormValue("code")))
}

func WeixinHdl(w http.ResponseWriter, r *http.Request){
	w.Write([]byte("Weixin Page"))
}

func QQHdl(w http.ResponseWriter, r *http.Request){
	w.Write([]byte("QQ Page"))
}

func ClientHdl(w http.ResponseWriter, r *http.Request){
	channel := r.FormValue("channel")
	openid  := r.FormValue("openid")
	publickey := r.FormValue("publickey")
	signature := r.FormValue("signature")

	rst := "channel:"+channel + " openid:"+openid +" publickey:"+publickey + " signature:"+signature
	w.Write([]byte([]byte(rst)))

}


func InitRouter() {
	http.HandleFunc("/",RootHdl)
	http.HandleFunc("/auth/weixin",WeixinHdl)
	http.HandleFunc("/auth/weibo",WeiboHdl)
	http.HandleFunc("/auth/qq",QQHdl)
	http.HandleFunc("/auth/client",handler.ClientHdl)
}







